package bigo.data;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author songliu
 */
public class VirtualColumnVector extends Vector {

    private int length, columnIndex;
    private Matrix m;

    public VirtualColumnVector(Matrix m, int columnIndex) {
        super(m.getColumnOffset());
        length = m.getNumRows();
        this.m = m;
        this.columnIndex = columnIndex;
    }

    @Override
    public Vector duplicate() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Vector subVector(int from, int to) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int length() {
        return length;
    }

    public int size() {
        return length;
    }

    public boolean isEmpty() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean containsKey(Object key) {
        return m.getRowVectorAt((Integer) key).containsKey(columnIndex);
    }

    public boolean containsValue(Object value) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Float get(Object key) {
        return m.getRowVectorAt((Integer) key).get(columnIndex);
    }

    public Float put(Integer key, Float value) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Float remove(Object key) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void putAll(Map<? extends Integer, ? extends Float> m) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void clear() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Set<Integer> keySet() {
        return new AbstractSet<Integer>() {

            @Override
            public Iterator<Integer> iterator() {
                return new Iterator<Integer>() {

                    int i = getOffset();

                    public boolean hasNext() {
                        return i < getOffset() + size();
                    }

                    public Integer next() {
                        int t = i;
                        i++;
                        return t;

                    }

                    public void remove() {
                        throw new UnsupportedOperationException("Not supported yet.");
                    }
                };

            }

            @Override
            public int size() {
                return length();
            }
        };
    }

    public Collection<Float> values() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Set<Entry<Integer, Float>> entrySet() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void write(DataOutput d) throws IOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void readFields(DataInput di) throws IOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
